import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: '/home/category'
    },
    {
      path: '/home',
      name: 'home',
      component: HomeView,
      alias: '/index',
      children: [
        {
          path: 'category',
          name: 'category',
          component: () => import('../views/exam/CategoryView.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginView.vue')
    }
    ,
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/RegisterView.vue')
    }
    ,
    {
      path: '/my',
      name: 'my',
      component: () => import('../views/user/MyView.vue')
    },
    ,
    {
      path: '/detail',
      name: 'detail',
      component: () => import('../views/exam/DetailView.vue')
    }
    ,
    {
      path: '/score',
      name: 'score',
      component: () => import('../views/exam/ScoreView.vue')
    }
    ,
    {
      path: '/testpaper',
      name: 'testpaper',
      component: () => import('../views/exam/TestPaper.vue')
    },
    {
      path: '/findpwd',
      name: 'findpwd',
      component: () => import('../views/user/FindPwd.vue')
    },
    {
      path: '/secure',
      name: 'secure',
      component: () => import('../views/user/SecureView.vue')
    },
    {
      path: '/edit',
      name: 'edit',
      component: () => import('../views/user/EditInfo.vue')
    },


    // 配置404... NotFound （在数组的末位）
    {
      // path:'*', vue2
      path: "/:pathMatch(.*)*",
      name: 'error',
      component: () => import('../views/ErrorView.vue')
    }
  ]
})

export default router
